package com.bwie.controller;

import com.bwie.pojo.TbType;
import com.bwie.service.TbTypeService;
import com.bwie.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author:Max
 * @Date: 2024/8/9 19:00
 * @Description
 **/
@RestController
@RequestMapping("/shop/type")
public class TbTypeController {
    @Autowired
    TbTypeService tbTypeService;

    /**
     * 产品类型图片上传
     */
    @PostMapping("/uploadFile")
    public Result uploadFile(@RequestPart("file") MultipartFile file) {
        return tbTypeService.uploadFile(file);
    }

    /**
     * 删除
     */
    @PostMapping("/deleteTypeById/{typeId}")
    public Result deleteTypeById(@PathVariable("typeId") Integer typeId) {
        return tbTypeService.deleteTypeById(typeId);
    }

    /**
     * 显示或者隐藏类型
     */
    @PostMapping("/setTypeStatus/{typeId}/{typeStatus}")
    public Result setTypeStatus(@PathVariable("typeId") Integer typeId, @PathVariable("typeStatus") Integer typeStatus) {
        return tbTypeService.setTypeStatus(typeId, typeStatus);
    }


    /**
     * 添加产品分类
     */
    @PostMapping("/addType")
    public Result addType(@RequestBody TbType type) {
        return tbTypeService.addtype(type);
    }

    /**
     * 修改商品类型信息
     */
    @PostMapping("/updateType")
    public Result updateType(@RequestBody TbType type){
        return  tbTypeService.updateType(type);
    }
}
